package online.xuping.common;

import cn.hutool.crypto.SecureUtil;
import online.xuping.thousandsOfWorlds.common.constants.ParamErrorCodeEnum;

public class PSWUtil {
    public static String mPsw(String src) {
        if (src == null) {
            return null;
        }
        String t=    SecureUtil.md5(src);
        return SecureUtil.md5(t.substring(0, 8)+ src+ t.substring(8));
    }

    /**
     *
     * @param src 密码
     * @param target 加密内容
     * @return
     */
    public static boolean checkPsw(String src, String target) {

        if (target == null) {
            throw ParamErrorCodeEnum.NOTNULL.exception();
        }

        return target.equals(mPsw(src));
    }
}
